﻿<?php

function smarty_modifier_substring($string, $from, $length = null)
{
    preg_match_all('/[\x80-\xff]?./', $string, $match);
    if(is_null($length))
    {
        $result = implode('', array_slice($match[0], $from));
    }
    else
    {
        $result = implode('', array_slice($match[0], $from, $length));
    }
    return $result;
}

?>